/**
 *用于提供注册和登录的表单验证
 */
	function showTip(showId) {
		var iselector = "#"+showId; 
		$(iselector).css({
			display: 'block',
			float: 'left'
		});
	}
	function hiddenTip(hiddenId) {
		var iselector = "#"+hiddenId;
		$(iselector).css({
			display: 'none',
			float: 'left'
		});
	}
	
	//验证邮箱
	function checkEmail(email) {
		var iEmail = $("#"+email).val();
		//如果为登录邮箱验证
		if(email == 'loginName') {
			if(iEmail != null && iEmail != '') {
				var regEmail = /^([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/;
				if(iEmail.match(regEmail)) {
					showTip('nameSuccessTip');
					hiddenTip('nameErrorTip');
					return true;
				}else {
					showTip('nameErrorTip');
					hiddenTip('nameSuccessTip');
					return false;
				}
			}else {
				showTip('nameErrorTip');
				hiddenTip('nameSuccessTip');
				return false;
			}
		}else {
			if(iEmail != null && iEmail != '') {
				var regEmail = /^([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/;
				if(iEmail.match(regEmail)) {
					showTip('emailSuccessTip');
					hiddenTip('emailErrorTip');
					return true;
				}else {
					showTip('emailErrorTip');
					hiddenTip('emailSuccessTip');
					return false;
				}
			}else {
				showTip('emailErrorTip');
				hiddenTip('emailSuccessTip');
				return false;
			}
		}
	}

	//验证手机号
	function checkPhone(phone) {
		var iPhone = $("#"+phone).val();
		//如果为登录手机号验证
		if(phone == 'loginName') {
			if (iPhone != null && iPhone != '') {
		 		var regTel = /^(1[3|4|5|6|8][0-9]{1})+\d{8}$/;
				if(iPhone.match(regTel)) {
					showTip('nameSuccessTip');
					hiddenTip('nameErrorTip');
					return true;
				}else {
					showTip('nameErrorTip');
					hiddenTip('nameSuccessTip');
					return false;
				}
			}else {
				showTip('nameErrorTip');
				hiddenTip('nameSuccessTip');
				return false;
			}
		}else {
			if (iPhone != null && iPhone != '') {
		 		var regTel = /^(1[3|4|5|6|8][0-9]{1})+\d{8}$/;
				if(iPhone.match(regTel)) {
					showTip('phoneSuccessTip');
					hiddenTip('phoneErrorTip');
					return true;
				}else {
					showTip('phoneErrorTip');
					hiddenTip('phoneSuccessTip');
					return false;
				}
			}else {
				showTip('phoneErrorTip');
				hiddenTip('phoneSuccessTip');
				return false;
			}
		}
	}

	//验证密码
	function checkPassword(password) {
		var iPassword = $("#"+password).val();
		if (iPassword != null && iPassword != '') {
			var validPassword = "1234567890qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM";
			if(iPassword.length >= 6 && iPassword.length <= 10) {
				for(var i=0;i<iPassword.length;i++) {
					if(validPassword.indexOf(iPassword.charAt(i), 0) < 0) {
						showTip('passwordErrorTip');
						hiddenTip('passwordSuccessTip');
						return false;
					}
				}
				showTip('passwordSuccessTip');
				hiddenTip('passwordErrorTip');
				return true;
			}else {
				showTip('passwordErrorTip');
				hiddenTip('passwordSuccessTip');
				return false;
			}
		}else {
			showTip('passwordErrorTip');
			hiddenTip('passwordSuccessTip');
			return false;
		}
	}
	
	//验证重复密码
	function checkRePassword() {
		var registPassword = $('#registPassword').val();
		var registRePassword = $('#registRePassword').val();
		if (registRePassword != null && registRePassword != '') {
			if(registRePassword == registPassword) {
				showTip('rePasswordSuccessTip');
				hiddenTip('rePasswordErrorTip');
				return true;
			}else {
				showTip('rePasswordErrorTip');
				hiddenTip('rePasswordSuccessTip');
				return false;
			}
		}else {
			showTip('rePasswordErrorTip');
			hiddenTip('rePasswordSuccessTip');
			return false;
		}
	}
	
	function checkLoginName(name) {
		var loginName = $("#"+name).val();
		//如果为电子邮箱
		if(loginName.indexOf('@') > 0) {
			if(!checkEmail(name)) {
				return false;
			}else {
				return true;
			}
		//否者验证是否为合法手机号
		}else {
			if(!checkPhone(name)) {
				return false;
			}else {
				return true;
			}
		}
	}
	
	
	